package com.maolong.spring.context.support;

import com.maolong.spring.beans.factory.support.ConfigurableListableBeanFactory;
import com.maolong.spring.beans.factory.support.DefaultListableBeanFactory;

public abstract class AbstractRefreshApplicationContext extends AbstractApplicationContext {

    private DefaultListableBeanFactory beanFactory;

    @Override
    protected void refreshBeanFactory(){
        this.beanFactory = createBeanFactory();
        loadBeanDefinitions(beanFactory);
    }

    @Override
    protected ConfigurableListableBeanFactory getBeanFactory()
    {
        return beanFactory;
    }

    protected abstract void loadBeanDefinitions(DefaultListableBeanFactory beanFactory);

    private DefaultListableBeanFactory createBeanFactory() {
         return new DefaultListableBeanFactory();
    }

}
